package www.wf.pro.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import www.wf.pro.entity.TokenEntity;
import www.wf.pro.mapper.AdminMapper;
import www.wf.pro.utils.RandomUtil;
import www.wf.pro.utils.RedisUtil;

import java.util.Date;

/**
 * @author wang fei
 * @date 2020-07-30 21:23
 */

@Transactional
public class BaseService {
    protected static Logger log = LoggerFactory.getLogger(BaseService.class);

    @Autowired
    protected AdminMapper adminMapper;

    @Autowired
    protected RedisUtil redisUtil;

    /**
     * 总后台
     */

    public TokenEntity createToken(Long id){
        TokenEntity entity = new TokenEntity();
        entity.setId(id);
        entity.setToken(RandomUtil.generateString(10) + "_" + id);
        entity.setLoginTime(currentDate());
        return  entity;
    }

    /**
     * 获取当前时间
     */
    public Date currentDate(){
        return new Date();
    }
}
